package com.wlw.eye.mvp.presenter

import android.content.Context
import com.wlw.eye.mvp.contract.FindDetailContract
import com.wlw.eye.mvp.model.FindDetailModel
import com.wlw.eye.utils.applyScheduler

class FindDetailPresenter(context: Context, view: FindDetailContract.View) : FindDetailContract.Presenter {


    var mContext: Context? = null
    var mView: FindDetailContract.View? = null
    var mModel: FindDetailModel? = null

    init {
        mContext = context
        mView = view
        mModel = FindDetailModel()
    }


    override fun requestData(categoryName: String, strategy: String) {
        var observable = mContext?.let { mModel?.load(it, categoryName, strategy) }
        observable?.applyScheduler()?.subscribe {
            mView?.setData(it)
        }
    }

    fun requestMoreData(start: Int, categoryName: String, strategy: String) {
        var observable = mContext?.let { mModel?.loadMore(it, start, categoryName, strategy) }
        observable?.applyScheduler()?.subscribe {
            mView?.setData(it)
        }
    }

    override fun start() {

    }
}

